﻿@model HZU.ZP.Domain.Model.Company
@{
    Layout = "_CompanyLayout";
}
<script type="text/javascript">
        $(document).ready(function () {
            $("button").click(function () {
                var $btn = $(this).button('loading');
                var Company = new Object();
                Company.Id = "@Model.Id";
                Company.CompanyNumber = $("#CompanyNumber").val();
                if (Company.CompanyNumber == '') {
                    alert("工商注册号不能为空！");
                    $btn.button('reset');
                    return false;
                }
                var file = $("#files").get(0);
                var files = file.files;
                var formdata = new FormData();
                if (files.length < 1) {
                    alert("请选择文件！");
                    $btn.button('reset');
                    return false;
                }
                for (var i = 0; i < files.length; i++) {
                    formdata.append("files", files[i]);
                }
                $.ajax({
                    type: 'Post',
                    data: formdata,
                    contentType: false,
                    processData: false,
                    url: "/Upload/FormImg",
                    success: function (result) {
                        if (result.returnCode == '999') {
                            alert('提交失败,重新尝试提交');
                            $btn.button('reset');
                            return false;
                        }
                        else if (result.returnCode == '4040') {
                            alert('文件不是.gif|.jpg|.jpeg|.png结尾');
                            $btn.button('reset');
                            return false;
                        }
                        else if (result.returnCode == '4050') {
                            alert('文件大于2M');
                            $btn.button('reset');
                            return false;
                        }
                        else {
                            Company.BusinessLicense = result.returnCode;

                            $.ajax({
                                type: "post",
                                url: "/Company/CompanyUpdate",
                                contentType: "application/json",
                                data: JSON.stringify(Company),
                                dataType: "json",
                                success: function (message) {
                                    if (message.returnCode == "001") {
                                        $btn.button('reset');
                                        alert("提交成功！");
                                        location.href = "/Position/GetComPosition?email=@User.Identity.Name&status=1";
                                    }
                                    else if (message.returnCode == '999') {
                                        alert("提交失败！无权限，请重新登录！");
                                        $btn.button('reset');
                                        location.href = "/Company/CompanyLogin";
                                    }
                                }
                            });
                        }
                    }
                });
            });
        });
</script>
<body>
    <div style="margin-top: 50px;">
        <div class="container">
            <div class="row clearfix">
                <div class="col-md-4 column">
                </div>
                <div class="col-md-4 column">
                    <form>
                        <div class="form-group">
                            <label>企业名称</label>
                            <input type="text" class="form-control" id="CompanyName" value="@Model.CompanyName" disabled="disabled" />
                        </div>
                        <div class="form-group">
                            <label>邮箱</label>
                            <input type="email" class="form-control" id="Email" value="@Model.Email" disabled="disabled" />
                        </div>
                        <div class="form-group">
                            <label>工商注册号</label>
                            <input type="text" class="form-control" id="CompanyNumber" value="@Model.CompanyNumber" required />
                        </div>
                        <div class="form-group">
                            <input type="file" id="files" value="选择需要上传的图片" accept=".jpg,.jpeg,.png" /><p style="color :red">支持.gif .jpg .jpeg .png文件</p>
                        </div>
                        <div class="form-group">
                            <label>审核意见</label>
                            <input type="text" class="form-control" value="@Model.Remark" />
                        </div>
                        <button type="button" id="register" class="btn btn-default btn-info btn-block" data-loading-text="提交中...">提交</button>
                    </form>
                </div>
                <div class="col-md-4 column">
                </div>
            </div>
        </div>
    </div>
</body>
    </html>


